home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / basic / PureBasic.lha / PureBasic_Demo / PureBasic / Examples / FullVersion_Sources / Commodity2.pb < prev    next >
Encoding:
Text File  |  2000-03-19  |  4.5 KB  |  181 lines

  1.  
  2. ; *************************************
  3. ;
  4. ; Commodity example file for Pure Basic
  5. ;
  6. ; © 1999 - Fantaisie Software -
  7. ;
  8. ; *************************************
  9.  
  10.  
  11. ; This example show some more advanced
  12. ; stuff for a Commodity, it's good to
  13. ; know the basics from Example 1.
  14. ;
  15. ; Open Execute Command and have the
  16. ; string gadget active when testing
  17. ; this example.
  18.  
  19.  
  20. DefType.InputXpression  ix1
  21.  
  22.   ix1\ix_Version   = #IX_VERSION  ;*  It's recommended that the section
  23.   ix1\ix_Class     = 2            ;*  in RKRM Libraries that describe
  24.   ix1\ix_Code      = 255          ;*  this structure is read befor it's
  25.   ix1\ix_CodeMask  = 0            ;*  used with other inputevents.
  26.   ix1\ix_Qualifier = 0
  27.   ix1\ix_QualMask  = 0
  28.   ix1\ix_QualSame  = 0
  29.  
  30.  
  31. DefType.InputEvent  ie1, ie2, ie3
  32.  
  33.   ie1\ie_NextEvent = ie2 ;        ;* Here is the 3 diffrent inputevent
  34.   ie1\ie_Class     = 1   ;        ;* that is used and added to the input
  35.   ie1\ie_Code      = 53  ; = b    ;* eventstream.
  36.  
  37.   ie2\ie_NextEvent = ie3 ;
  38.   ie2\ie_Class     = 1   ;
  39.   ie2\ie_Code      = 54  ; = n
  40.  
  41.   ie3\ie_NextEvent = 0   ;
  42.   ie3\ie_Class     = 1   ;
  43.   ie3\ie_Code      = 55  ; = m
  44.  
  45.  
  46.   name$="Pure Basic Commodity"
  47.   title$="Commodity V1.00"
  48.   disc$="Testing"
  49.  
  50.  
  51.   PrintN("")
  52.   PrintN("////////////////////////////////////////////////")
  53.   PrintN("Open Execute Command in WorkBench menu.")
  54.   PrintN("Press F1 to add a new inputevent.")
  55.   PrintN("Press F2 to delete all Objects.")
  56.   PrintN("Press F3 to turn on/off Translater for Object 4.")
  57.   PrintN("Press F4 to turn on/off Object 4.")
  58.   PrintN("Mouse is Object 4, move it around a bit.")
  59.   PrintN("////////////////////////////////////////////////")
  60.   PrintN("")
  61.  
  62.  
  63.   If InitCommodity(4,name$,title$,disc$,0,0)
  64.  
  65.  
  66.     err.b=CreateCommodityObject(0,"f1",0)     ;* Object 0 is tied to f1 key
  67.  
  68.     err=CreateCommodityObject(1,"f2",0) | err ;* Object 1 is tied to f2 key
  69.  
  70.     err=CreateCommodityObject(2,"f3",0) | err ;* Object 2 is tied to f3 key
  71.  
  72.     err=CreateCommodityObject(3,"f4",0) | err ;* Object 3 is tied to f4 key
  73.  
  74.     err=CreateCommodityObject(4,"f9",0) | err ;* Object 4 is tied to f9 key
  75.  
  76.  
  77.     err=ChangeCommodityFilterIX(4,@ix1) | err  ;* Object 4 is changed to mouse
  78.                                               ;* with an InputXpression
  79.  
  80.     ActivateCommodityObject(4,0)              ;* Object 4 is deativated..
  81.     ChangeCommodityTranslater(4,@ie1)          ;* the translater is changed..
  82.     ActivateCommodityTranslater(4,0)          ;* and also deactivated
  83.  
  84.  
  85.     If err = 0
  86.  
  87.       ActivateCommodity(1)
  88.   
  89.  
  90.       Repeat
  91.  
  92.       WaitCommodityEvent()
  93.   
  94.       If CommoditySignal()
  95.  
  96.         msgtype.w=CommodityType()
  97.         msgid.w=CommodityID()
  98.  
  99.         Select msgtype
  100.  
  101.          Case #CXM_IEVENT
  102.            Print("IEvent: ID=") : PrintNumber(msgid)
  103.  
  104.            Select msgid
  105.  
  106.             Case 0
  107.               PrintN("  F1 was pressed.. A new input event is added.")
  108.               AddCommodityInputEvent(@ie3) ;* a new inputevent is added to
  109.                                           ;* the input eventstream
  110.             Case 1
  111.               Print("  F2 was pressed..")
  112.  
  113.               For c=0 to 4
  114.                 FreeCommodityObject(c)    ;* all Objects is deleted here
  115.               Next
  116.  
  117.               PrintN (" All Objects are deleted.")
  118.  
  119.             Case 2
  120.               Print("  F3 was pressed..")
  121.  
  122.               active2=1-active2
  123.  
  124.               If active2
  125.                 PrintN(" Translater for Object 4 is ON.")
  126.               Else
  127.                 PrintN(" Translater for Object 4 is OFF.")
  128.               EndIf
  129.  
  130.               ActivateCommodityTranslater(4,active2) ;* the translater for
  131.                                                      ;* Object 4 is turned
  132.             Case 3                                   ;* on or off here
  133.               Print("  F4 was pressed..")
  134.  
  135.               active1=1-active1
  136.  
  137.               If active1
  138.                 PrintN(" Object 4, Mouse, is ON.")
  139.               Else
  140.                 PrintN(" Object 4, Mouse, is OFF.")
  141.               EndIf
  142.  
  143.               ActivateCommodityObject(4,active1)     ;* Object 4 is turned
  144.                                                      ;* on or off here
  145.             Case 4
  146.               PrintN("  Mouse was used.")
  147.  
  148.            EndSelect
  149.   
  150.  
  151.          Case #CXM_COMMAND
  152.  
  153.            Select msgid
  154.  
  155.             Case #CXCMD_KILL
  156.               quit=1
  157.  
  158.             Case #CXCMD_UNIQUE
  159.               quit=1
  160.  
  161.            EndSelect
  162.  
  163.         EndSelect
  164.  
  165.       EndIf
  166.   
  167.  
  168.       If CommodityCtrlCSignal()
  169.         quit=1
  170.       EndIf
  171.   
  172.  
  173.       Until quit = 1
  174.  
  175.     EndIf
  176.  
  177.   EndIf
  178.   PrintN("End of Program.") 
  179.  
  180.   End
  181.